home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 September / macformat-028.iso / mac / Shareware City / Developers / BoxMaker++ / Monochromize ƒ / Monochromize.cp < prev    next >
Encoding:
Text File  |  1995-06-14  |  2.1 KB  |  111 lines  |  [TEXT/KAHL]

  1. #include <assert.h>
  2.  
  3. #include <fstream.h>
  4.  
  5. #include <Types.h>
  6. #include <Memory.h>
  7. #include <QuickDraw.h>
  8. #include <OSUtils.h>
  9. #include <ToolUtils.h>
  10. #include <Menus.h>
  11. #include <Packages.h>
  12. #include <Traps.h>
  13. #include <Files.h>
  14. #include <Aliases.h>
  15. #include <AppleEvents.h>
  16. #include <GestaltEqu.h>
  17. #include <Processes.h>
  18. #include <Fonts.h>
  19. #include <OSEvents.h>
  20. #include <Resources.h>
  21. #include <Desk.h>
  22.  
  23. #include <Windows.h>
  24. #include <QDOffscreen.h>
  25. #include <SegLoad.h>
  26. #include <TextEdit.h>
  27.  
  28. #include "grafport.h"
  29. #include "gworld.h"
  30.  
  31. #include "standardgetfile.h"
  32. #include "boxmakergetfile.h"
  33.  
  34. #include "boxmaker constants.h"
  35. #include "boxmaker.h"
  36. #include "Monochromize.h"
  37.  
  38. void main();
  39.  
  40. void main()
  41. {
  42.     eight_to_one it;
  43.     it.run();
  44. }
  45.  
  46. void eight_to_one::OpenDoc( Boolean opening)
  47. {
  48.     short refNum;
  49.     FSpOpenDF( &theFSSpec, fsRdWrPerm, &refNum);
  50.     
  51.     long picture_size;
  52.     OSErr result;
  53.     
  54.     result = GetEOF( refNum, &picture_size);
  55.     
  56.     picture_size -= 0x0200;
  57.  
  58.     result = SetFPos( refNum, fsFromStart, 0x0200); 
  59.  
  60.     PicHandle thePICT = (PicHandle)NewHandle( picture_size);
  61.     HLock( (Handle)thePICT);
  62.         result = FSRead( refNum, &picture_size, (char *)*thePICT);
  63.         Rect PICTRect = (**thePICT).picFrame;
  64.     HUnlock( (Handle)thePICT);
  65.     
  66.     OffsetRect( &PICTRect, -PICTRect.left, -PICTRect.top);
  67.     
  68.     gworld offscreen( PICTRect.right, PICTRect.bottom, 1);
  69.     offscreen.use();
  70.     DrawPicture( thePICT, &PICTRect);
  71.     DisposeHandle( (Handle)thePICT);
  72.     
  73.     thePICT = OpenPicture( &PICTRect);
  74.     offscreen.copyfrom( offscreen);
  75.     ClosePicture();
  76.     long new_size = GetHandleSize( (Handle)thePICT);
  77.     //
  78.     // Keep the old header
  79.     //
  80.     result = SetFPos( refNum, fsFromStart, 0x0200); 
  81.     result = SetEOF( refNum, new_size + 0x200);
  82.     result = FSWrite( refNum, &new_size, (char *)*thePICT);
  83.     KillPicture( thePICT);
  84.     result = FSClose( refNum);
  85. }
  86.  
  87. void eight_to_one::DoMenu( long retVal)
  88. {
  89.     const short menuID = HiWord( retVal);
  90.     const short itemID = LoWord( retVal);
  91.  
  92.     switch( menuID)
  93.     {
  94.         case kAppleMenuID:
  95.             DoAppleMenu( itemID);
  96.             break;
  97.             
  98.         case kFileMenuID:
  99.             switch( itemID)
  100.             {
  101.                 case kSelectFileItem:
  102.                     SelectFile();
  103.                     break;
  104.                 
  105.                 case kPrefsItem:    // _not_ kQuitItem!!
  106.                     SendQuitToSelf();
  107.                     break;
  108.             }
  109.     }
  110. }
  111.